﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace InnovTech.IO
{
    public static class StreamExtension
    {
        /// <summary>
        /// Resets the pivot of the given <see cref="Stream"/> to the start point(0).
        /// </summary>
        /// <param name="stream">A <see cref="Stream"/></param>
        public static void Reset(this Stream stream)
        {
            if (stream.CanSeek)
                stream.Position = stream.Seek(0, SeekOrigin.Begin);
        }

        /// <summary>
        /// Sets the access position of the <see cref="Stream"/>
        /// </summary>
        /// <param name="stream">A <see cref="Stream"/></param>
        /// <param name="pos">The access position</param>
        public static void Seek(this Stream stream, long pos)
        {
            if (stream.CanSeek)
                stream.Position = pos;
        }
    }
}
